Geometric Operations
QuickDraw GX provides functions that allow you to modify the geometries of geometric shapes, obtain information about their geometries, and combine the geometries of
two shapes.One such geometric operation allows you to remove unnecessary or redundant geometric points from the shape's geometry--this process is called reducing a geometry.
Figure 1-7 shows a polygon geometry with two unnecessary geometric points:
Figure 1-7 An example of reducing a shape
- Point 2 lies on the same line as points 1 and 3, and therefore has no effect on the geometry.
- Points 4 and 5 lie on top of one another, and so only one of them is necessary for this geometry.
In addition to unnecessary geometric points, a shape geometry can have a number of other complicating qualities, such as crossed edges or overlapping contours. QuickDraw GX provides a geometric operation that redefines a shape's geometry to eliminate these qualities. This process is called simplifying a shape. Figure 1-8 shows a polygon contour with two edges that cross and the result of simplifying this shape.
Figure 1-8 An example of simplifying a shape
As Figure 1-8 shows, simplifying the polygon geometry splits it into two contours: an upper triangular contour with three geometric points, and a lower triangular contour with three geometric points. Although the simplified geometry contains more geometric points and more contours than the original, it does not contain any crossed edges.
You can find more about reducing and simplifying shape geometries in the chapter "Geometric Operations" in this book. That chapter also describes many functions that allow you to obtain information about geometric shapes and perform geometric arithmetic on them. Figure 1-9 shows some examples of the different types of geometric information that QuickDraw GX calculates for you.
Figure 1-9 Some examples of the geometric information available about a shape
You can find more about geometric information in the "Geometric Operations" chapter of this book.
Another important type of geometric operation is geometric arithmetic. Figure 1-10 shows examples of intersection, union, difference, reverse difference, and exclusion operations, which each return a result calculated by combining the geometries of two shapes in different ways.
Figure 1-10 Some examples of the geometric arithmetic you can perform with shapes
Other geometric operations provided by QuickDraw GX allow you to
These geometric operations are all discussed in the chapter "Geometric Operations" in this book.
- alter the order of the geometric points specified in a shape's geometry
- break a single shape contour into multiple contours
- calculate whether two shapes intersect
- calculate whether one shape contains another shape
- inset the geometric points of a shape's geometry
- scale the shape to fit in a new bounding rectangle
- invert the geometry of a shape
The chapter "Transform Objects" in Inside Macintosh: QuickDraw GX Objects describes a related set of functions you can use to perform geometric modifications to a shape's geometry. These functions allow you to
Depending on the setting of a shape's map-transform shape attribute, these functions either modify the mapping matrix contained in the shape's transform object or recalculate the geometric points contained in the shape's geometry directly.
- move a shape
- rotate a shape
- scale a shape
- skew a shape
- perform any arbitrary mapping on a shape
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help